package com.sanjiahantang.youjiaclient.module.common.beans;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.sanjiahantang.youjiaclient.base.BaseBean;
import com.sanjiahantang.youjiaclient.config.StaticValue;

import org.json.JSONException;
import org.json.JSONObject;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by zy on 2017/11/2.
 */

public class FileBean extends BaseBean implements StaticValue{
    private String data;

    public Data getData() {
        Gson gson = new Gson();
        StringBean bean = gson.fromJson(data,StringBean.class);
        try {
            return gson.fromJson(bean.getData(),Data.class);
        }catch (Exception e){
            return null;
        }

    }

    public int getSuperCode(){
        return super.getCode();
    }

    @Override
    public int getCode() {
        if (super.getCode() == RESPONSE_CODE_SUC){
            Gson gson = new Gson();
            try {

                StringBean bean = gson.fromJson(data,StringBean.class);
                return bean.getCode();
            }catch (Exception e){
                return RESPONSE_CODE_FAIL;
            }
        }
        return super.getCode();
    }

    @Override
    public String getMessage() {
        if (super.getCode() == RESPONSE_CODE_SUC){
            Gson gson = new Gson();
            StringBean bean = gson.fromJson(data,StringBean.class);
            return bean.getMessage();
        }
        return super.getMessage();
    }

    public List<Data> getList(){
        return new Gson().fromJson(data,new TypeToken<List<Data>>(){}.getType());
    }

    public void setData(String data) {
        this.data = data;
    }



    public static class Data {


        private int mallId;
        private String name;
        private int size;
        private String type;
        private String busiId;
        private String groupId;
        private String url;
        private int planId;

        public void setPlanId(int planId) {
            this.planId = planId;
        }

        public int getMallId() {
            return mallId;
        }

        public void setMallId(int mallId) {
            this.mallId = mallId;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getSize() {
            return size;
        }

        public void setSize(int size) {
            this.size = size;
        }

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public String getBusiId() {
            return busiId;
        }

        public void setBusiId(String busiId) {
            this.busiId = busiId;
        }

        public String getGroupId() {
            return groupId;
        }

        public void setGroupId(String groupId) {
            this.groupId = groupId;
        }

        public String getUrl() {
            return url;
        }

        public void setUrl(String url) {
            this.url = url;
        }

        public int getPlanId() {
            return planId;
        }
    }
}
